<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import="java.util.*" %>
  
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>   
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
	String[] zones=TimeZone.getAvailableIDs();	//获得所有的id
	pageContext.setAttribute("zone", zones);
 	out.println("<table>");
	for(int i=0;i<zones.length;i++){
		TimeZone tz=TimeZone.getTimeZone(zones[i]);	//获得所在id的当前时区
		out.println("<tr>");
		out.println("<td>"+zones[i]+"</td>");
		out.println("<td>"+tz.getDisplayName()+"</td>");
		out.println("<td>"+tz.getRawOffset()/(60*60*1000)+"</td>");	//获取相差的时间
		out.println("</tr>");
	}
	out.println("</table>");	
%>
<c:set var="now" value="<%=new java.util.Date() %>"></c:set>
<p>当前本地时间：<fmt:formatDate value="${now }" type="both"/></p>
<%-- <fmt:setTimeZone value="GMT-8"/> --%>
<fmt:timeZone value="GMT-8">
<p>当前时区时间：<fmt:formatDate value="${now }" type="both"/></p>
</fmt:timeZone>
<%
out.println(new java.util.Date().toString());
%>
</body>
</html>